/**
 * Created by spatra on 15-1-6.
 */

define(['lessonDiscussionJS/module'], function(lessonDiscussionModule){

  /**
   * 此服务用于 课程-讨论 的获取和添加评论等操作
   */
  lessonDiscussionModule.factory('DiscussionService', ['$http', 'NestedResourceService',
    function($http, NestedResourceService){

      return {
        accessor: NestedResourceService.getResourceAccessor({
          parentResourceName: 'lesson',
          nestedResourceName: 'discussion'
        }),
        addReply: function(data, stateParams){
          var self = this;

          if( stateParams ){
            self.accessor['setParentResourceId'](stateParams);
          }

          return $http.post([
            self.accessor.getBaseUrl(), stateParams['discussionId'], 'reply'
          ].join('/'), data);
        }
      };

    }]);//End of --> DiscussionService
});